package ignite.service.impl;

import ignite.repository.PersonRepository;
import ignite.service.PersonService;
import lombok.AllArgsConstructor;
import org.ignite.entity.Person;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.cache.Cache;
import java.util.List;

@Service
@AllArgsConstructor
public class PersonServiceImpl implements PersonService {
    private PersonRepository personRepository;

    @Override
    public List<Cache.Entry<Integer, Person>> findByFirstName(String name) {
        return personRepository.findByFirstName(name);
    }

    @Override
    public List<Integer> selectId(Integer Id, Pageable pageable) {
        return personRepository.selectId(Id, pageable);
    }

    @Override
    public List<Cache.Entry<Integer, Person>> selectAll(Pageable pageable) {
        return personRepository.selectAll(pageable);
    }

    @Override
    public Integer getMaxId() {
        return personRepository.getMaxId();
    }

    @Override
    public List<Cache.Entry<Integer, Person>> findByManyParams(Integer Id, String firstName) {
        return personRepository.findByManyParams(Id, firstName);
    }

    @Override
    public void updateById(Integer Id, String firstName) {
        personRepository.updateById(Id, firstName);
    }

    @Override
    public void deleteById(Integer Id) {
        personRepository.deleteById(Id);
    }

    @Override
    public Person selectPersonById(Integer id) {
        return personRepository.selectPersonById(id);
    }

    @Override
    public Person save(Person person) {
        return personRepository.save(person.getId(),person);
    }
}
